<template>
  <div style="margin-top: 1vw" class="mycard">
    <span class="words">查询出下列歌手<i class="el-icon-arrow-right"></i></span>
    <el-row>
      <el-col :span="3" v-for="(item, index) in singerList" :key="index" :offset="index % 5 == 0 ? 0 : 2">
        <el-card :body-style="{ padding: '0px' }" style="width: 13.1vw">
          <img :src="item.pic" class="image" style="height:14vw">
          <div style="padding: 10px; text-align: center;">
            <span>{{ item.srname }}</span>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>
  
<script>
export default {
  name: "SearchView",
  components: {

  },
  data() {
    return {
      singerList: [],

    }
  },
  watch: {
    '$route'(to, from) {

      this.getSingerList();

    }
  },
  created() {
    this.getSingerList();
  },
  methods: {
    async getSingerList() {

      if(!this.$route.query.singername) {
                const res = await this.$http.get('music/findAllSongerBean');
                this.singerList = res.data.data;
                this.$message.success(res.data.msg);
            }else{
                const res = await this.$http.get('music/findSonger', { params: { name: this.$route.query.singername } });
                this.singerList = res.data.data;
                this.$message.success(res.data.msg);
            }
    },
  }
};
</script>
  
<style scoped>
  .words {
    font-size:2rem;
    padding-left: 20px;
    color: #ffffff;
    text-shadow: -3px -2px 3px #dbdada, 4px 3px 3px #444444;
  }
  .mycard {
    padding-top: 20px;
    padding-bottom: 10px;
    background: rgba(255, 255, 255, 0.2);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border-radius: 10px;
    box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.2);
  }
  
  .el-card {
    margin-top: 30px;
  }
  .el-card__header {
    background: #5a8cbb;
    color: #ffffff;
  }
  .cardfenlei {
    height: 14vw
  }

  .image {
    width: 100%;
    display: block;
  }
</style>